package cate.game.role.farm.island.cell;

import cate.common.table.d.GDIsland;
import cate.game.GameBody;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "商店格子")
public class MallCell extends IslandCell {

    public MallCell() {
        this.type = GDIsland.CellType.MALL;
    }

    @NoteField(value = "商品id们")
    public List<Integer> items = new ArrayList<>();

    @NoteField(value = "购买的商品id")
    public List<Integer> buyItems = new ArrayList<>();

    @Override
    public void initialize(GameBody gameBody) {
        items.removeIf(a -> gameBody.table.island.shopItem.get(a) == null);
    }

    public MallCell setItems(List<Integer> items) {
        this.items = items;
        return this;
    }

    public Integer getItemsByIndex(int index) {
        if (items.size() > index && index >= 0) {
            return items.get(index);
        }
        return null;
    }

    @Override
    public String toString() {
        return super.toString() + "商店格子";
    }
}
